<?php
/**
 * @link https://www.kancloud.cn/cleverstone/ymb2
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */

namespace builder\tree_table\util\tttcustom;

use builder\helper\App;
use builder\helper\Url;

/**
 * 工具栏类型接口
 * @author cleverstone
 * @since ym2.0
 */
abstract class TCustomType
{
    /**
     * @return array
     */
    abstract public function _toArray();

    /**
     * RBAC检查
     * @param string $route 路由或外链
     * @return bool
     */
    protected function checkAccess($route)
    {
        return App::rbacManager()->permissionValidate($route);
    }

    /**
     * 标准化路由
     * @param string|array $route
     * @return string
     */
    protected function normalizeRoute($route)
    {
        if (empty($route)) {
            return Url::current([], '');
        } else {
            return Url::to($route, '');
        }
    }
}